package com.harry.editsearchhistory.util;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

/**
 * @author Martin-harry
 * @date 2022/3/2
 * @address
 * @Desc 键盘工具类
 */
public class KeyboardUtils
{
    /**
     * 打开
     */
    public static void openKeyboard(Context context, View editText)
    {
        InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.showSoftInput(editText, 0);
    }

    public static void closeKeyboard(Context context, View editText)
    {
        InputMethodManager inputMethodManager
                = (InputMethodManager)
                context.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);
    }
}
